package com.tanhua.server.job;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * @Created by ${smh} on 2020/12/14.
 */
@Service
public class PeachJob {


    @Autowired
    private RedisTemplate<String,String> redisTemplate;

    //定时任务每天凌晨 5 点更新
    @Scheduled(cron = "0 0 5 * * ?")
    public void run(){
        //模糊查询所有以 PEACHBLOSSOM_ 开头的key
        Set<String> keys = redisTemplate.keys("PEACHBLOSSOM_*");
        //删除查到的key
        this.redisTemplate.delete(keys);
    }
}
